<template>
    <div class="bg-gray" style="min-height: 100vh;">
        <van-tabs v-model="tabActive" swipeable class="tab-theme tab-bgGray">
            <van-tab :name="1" :title="$t('Cpxin')">
                <tab1_purchase :tabActive = "tabActive"
                               v-if=" tabActive == 1 "/>
            </van-tab>
            <van-tab :name="2" :title="$t('Jiang')">
                <tab2_ongoing v-if="tabActive == 2" :tabActive = "tabActive" @fnBackTab="fnBackTab" />
            </van-tab>
            <van-tab :name="3" :title="$t('Quxiao')">
                <tab2_ongoing :tabActive = "tabActive"
                              v-if=" tabActive == 3 "/>
            </van-tab>
        </van-tabs>
    
    </div>
</template>

<script>
import tab1_purchase from "@/views/trade/components/tab1_purchase";
import tab2_ongoing from "@/views/trade/components/tab2_ongoing";

export default {
    name: "login",
    components: {
        tab1_purchase,
        tab2_ongoing,
    },
    data() {
        return {
            tabActive: 1,
        };
    },
    methods: {
        /* 切换 */
        fnBackTab(index){
            if(index){
                this.tabActive = index;
                return
            }
            
            const trade_tab_active = Number(localStorage.getItem("trade_tab_active"));
            if(trade_tab_active){
                this.tabActive = trade_tab_active;
            }
            setTimeout(()=>{
                localStorage.removeItem("trade_tab_active");
            },1000)
        
        },
    },
    created() {
        // const market_tab_active = localStorage.getItem("trade_tab_active");
        // if (market_tab_active) {
        //     this.tabActive = Number(market_tab_active);
        // }
        this.fnBackTab();
    },
    
};
</script>
